<template>
  <div class="auditRecords">
    <!-- 审核记录 -->
    <FilterTable
      ref="table"
      height="auto"
      :dataSource="dataSource"
      :columns="columns"
      :onColumnsChange="columns => this.columns = columns"
    />

    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button size="small" type="primary" @click="closeDialog">关 闭</el-button>
    </div>


  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { auditRecords } from '@/api/retail/salesmanage/salesordermanage';
export default {
  name: 'auditRecords',
  mixins: [dictionary],
  props: {
    rowData: {
      type: Object,
      default: () => ({})
    }
  },
  data (){
    return {
      columns: this.createTableColumns(), //table数据
      dataSource:[],
      params:{
        pageNum: 1,
        currentPage: 1,
        pageSize: 20,
        limit: 20,
      }

    }
  },
  mounted (){
    this.init();
  },
  methods: {
    init (){
      auditRecords(this.rowData.soNoId, this.params).then(res => {
        // console.log(res)
        this.dataSource = res.data.records;
      }).catch(err => {
        // console.log(err)
      })
    },
    createTableColumns (){ //table数据
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '客户订单号',
          dataIndex: 'soNo',
          width: 150,
          sorter: true,
          filter: true,
          showOverflowTooltip:true,
          filterType: 'input',
        },
        {
          title: '提交时间',
          dataIndex: 'submitTime',
          width: 150,
          dateFormat: 'yyyy-MM-dd',
          sorter: true,
          filter: true,
          showOverflowTooltip:true,
          filterType: 'date-range',
          editable: false,
          editType: 'date-picker'
        },
        {
          title: '审核时间',
          dataIndex: 'auditingDate',
          width: 150,
          showOverflowTooltip:true,
          dateFormat: 'yyyy-MM-dd',
          sorter: true,
          filter: true,
          filterType: 'date-range',
          editable: false,
          editType: 'date-picker'
        },
        {
          title: '审核结果',
          dataIndex: 'auditingResult',
          showOverflowTooltip:true,
          render: props => {
            return <span>{this.preDictSpecialHandler(props.row.auditingResult, props.row.auditedByIdentity)}</span>;
          }
        },
        {
          title: '审核人',
          dataIndex: 'auditedBy',
          showOverflowTooltip:true,
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '处理意见',
          dataIndex: 'auditingPostil',
          sorter: true,
          filter: true,
          showOverflowTooltip:true,
          filterType: 'input',
        },

      ]
    },
    closeDialog (param){
      this.$emit('close', false, param)
    },
    preDictSpecialHandler (auditingResult, auditedByIdentity) {
      // auditingResult :1416, auditedByIdentity: 1417
      let str = ''
      if (auditingResult == 14161001 && auditedByIdentity == 14171001) {
        str = '财务审核通过'
      } else if (auditingResult == 14161003) {
        str = '经理审核通过'
      } else if (auditingResult == 14161002 && auditedByIdentity == 14171001) {
        str = '财务审核驳回'
      } else if (auditingResult == 14161002 && auditedByIdentity == 14171002) {
        str = '经理审核驳回'
      }
      return str
    }

  },

}
</script>

<style scoped lang="less">
</style>
